package edu.washington.cs.sounddetector.server.api.methodresult;

import java.util.List;

import edu.washington.cs.sounddetector.server.api.MethodResult;
import edu.washington.cs.sounddetector.server.api.method.Train;

public class TrainResult extends MethodResult<Train>
{

    private List<Long> soundIds;
    private String message;

    private TrainResult(boolean successful, FailureReason reason, String message,
            List<Long> soundIds)
    {
        super(successful, reason);
        this.message = message;
        this.soundIds = soundIds;
    }

    private TrainResult()
    {
        this(true, null, null, null);
    }

    /**
     * @return if this.successful() == false, then the message as to why the classifier could not be
     *         built. If this.successful() == true, then returns null.
     */
    public String getMessage()
    {
        return this.message;
    }

    /**
     * @return if this.successful() == true, then returns a list of ids for the sounds which were
     *         sent in the Train API call. If this.successful() == false, returns null.
     */
    public List<Long> getSoundIds()
    {
        return this.soundIds;
    } 

    /**
     * Successful TrainResult.
     * 
     * @param soundIds
     *            the ids corresponding to the sounds that were sent in the Train api call.
     */
    public static TrainResult success(List<Long> soundIds)
    {
        return new TrainResult(true, null, null, soundIds);
    }

    public static TrainResult failureCantBuildClassifier(String message)
    {
        return new TrainResult(false, FailureReason.CANT_BUILD_CLASSIFIER, message, null);
    }

}
